# -*- coding: utf-8 -*-

import stanfordnlp

class StanfordNLPSegmenter:
    def __init__(self):
        stanfordnlp.download('zh')  # 下载中文模型
        self.nlp = stanfordnlp.Pipeline(lang='zh')

    def segment(self, text):
        doc = self.nlp(text)
        return [word.text for sentence in doc.sentences for word in sentence.words]
